package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.DimeSerialNumber;
import com.ruoyi.system.service.IDimeSerialNumberService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2023-10-11
 */
@RestController
@RequestMapping("/dimeserialnumber")
public class DimeSerialNumberController extends BaseController
{
    @Autowired
    private IDimeSerialNumberService dimeSerialNumberService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:number:list")
    @GetMapping("/list")
    public TableDataInfo list(DimeSerialNumber dimeSerialNumber)
    {
        startPage();
        List<DimeSerialNumber> list = dimeSerialNumberService.selectDimeSerialNumberList(dimeSerialNumber);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:number:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DimeSerialNumber dimeSerialNumber)
    {
        List<DimeSerialNumber> list = dimeSerialNumberService.selectDimeSerialNumberList(dimeSerialNumber);
        ExcelUtil<DimeSerialNumber> util = new ExcelUtil<DimeSerialNumber>(DimeSerialNumber.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("system:number:query")
    @GetMapping(value = "/{shopCode}")
    public AjaxResult getInfo(@PathVariable("shopCode") String shopCode)
    {
        return success(dimeSerialNumberService.selectDimeSerialNumberByShopCode(shopCode));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("system:number:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DimeSerialNumber dimeSerialNumber)
    {
        return toAjax(dimeSerialNumberService.insertDimeSerialNumber(dimeSerialNumber));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:number:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DimeSerialNumber dimeSerialNumber)
    {
        return toAjax(dimeSerialNumberService.updateDimeSerialNumber(dimeSerialNumber));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:number:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopCodes}")
    public AjaxResult remove(@PathVariable String[] shopCodes)
    {
        return toAjax(dimeSerialNumberService.deleteDimeSerialNumberByShopCodes(shopCodes));
    }

    @GetMapping(value = "/occupationalreportno")
    public R<String> getOccupationalReportNo()
    {
        return R.ok(dimeSerialNumberService.getOccupationalReportNo());
    }
}
